package com.syy.writableComparable;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class FlowPhone implements WritableComparable<FlowPhone> {
    private Long up;
    private Long down;
    private Long sum;

    public FlowPhone() {
    }

    public FlowPhone(Long up, Long down, Long sum) {
        this.up = up;
        this.down = down;
        this.sum = sum;
    }

    public Long getUp() {
        return up;
    }

    public void setUp(Long up) {
        this.up = up;
    }

    public Long getDown() {
        return down;
    }

    public void setDown(Long down) {
        this.down = down;
    }

    public Long getSum() {
        return sum;
    }

    public void setSum(Long sum) {
        this.sum = sum;
    }

    @Override
    public String toString() {
        return up + "\t" + down + "\t" + sum;
    }

    @Override
    public int compareTo(FlowPhone o) {
        return o.getSum().compareTo(this.getSum());
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeLong(up);
        dataOutput.writeLong(down);
        dataOutput.writeLong(sum);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.up = dataInput.readLong();
        this.down = dataInput.readLong();
        this.sum = dataInput.readLong();
    }
}
